package com.limanyik.family.security.controller;

import com.limanyik.family.common.entity.server.security.UserLogin;
import com.limanyik.family.common.utils.FamilyHttpRequest;
import com.limanyik.family.common.utils.FamilyHttpResponse;
import com.limanyik.family.security.entity.WebLoginData;
import com.limanyik.family.security.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;


@RestController
public class LoginController {

    @Resource(name = "loginServiceImpl")
    LoginService loginService;

    /**
     * web登录接口
     *
     * @param familyHttpRequest
     * @param response
     * @return
     */
    @PostMapping("/web/login")
    public FamilyHttpResponse<WebLoginData> login(@RequestBody FamilyHttpRequest<UserLogin> familyHttpRequest, HttpServletResponse response) {
        return loginService.webLogin(familyHttpRequest, response);
    }

    @PostMapping("/test")
    public FamilyHttpResponse test() {
        return FamilyHttpResponse.success();
    }

}
